diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2007-05-02 13:27:14 -0400 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2007-05-02 13:27:14 -0400 |
commit | 63f70270ccd981ce40a8ff58c03a8c2e97e368be (patch) | |
tree | 7ffe766f25007845c99cfc337365c3006a153b83 /include/asm-i386/paravirt.h | |
parent | 294688c028e80fd467cdd22da79f62c5f311eaf5 (diff) |
[PATCH] i386: PARAVIRT: add common patching machinery
Implement the actual patching machinery. paravirt_patch_default()
contains the logic to automatically patch a callsite based on a few
simple rules:
- if the paravirt_op function is paravirt_nop, then patch nops
- if the paravirt_op function is a jmp target, then jmp to it
- if the paravirt_op function is callable and doesn't clobber too much
for the callsite, call it directly
paravirt_patch_default is suitable as a default implementation of
paravirt_ops.patch, will remove most of the expensive indirect calls
in favour of either a direct call or a pile of nops.
Backends may implement their own patcher, however. There are several
helper functions to help with this:
paravirt_patch_nop nop out a callsite
paravirt_patch_ignore leave the callsite as-is
paravirt_patch_call patch a call if the caller and callee
have compatible clobbers
paravirt_patch_jmp patch in a jmp
paravirt_patch_insns patch some literal instructions over
the callsite, if they fit
This patch also implements more direct patches for the native case, so
that when running on native hardware many common operations are
implemented inline.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Acked-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-i386/paravirt.h')
-rw-r--r-- | include/asm-i386/paravirt.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h index 8bfaf10d9961..4b3d50858670 100644 --- a/include/asm-i386/paravirt.h +++ b/include/asm-i386/paravirt.h | |||
@@ -248,6 +248,18 @@ extern struct paravirt_ops paravirt_ops; | |||
248 | #define paravirt_alt(insn_string) \ | 248 | #define paravirt_alt(insn_string) \ |
249 | _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]") | 249 | _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]") |
250 | 250 | ||
251 | unsigned paravirt_patch_nop(void); | ||
252 | unsigned paravirt_patch_ignore(unsigned len); | ||
253 | unsigned paravirt_patch_call(void *target, u16 tgt_clobbers, | ||
254 | void *site, u16 site_clobbers, | ||
255 | unsigned len); | ||
256 | unsigned paravirt_patch_jmp(void *target, void *site, unsigned len); | ||
257 | unsigned paravirt_patch_default(u8 type, u16 clobbers, void *site, unsigned len); | ||
258 | |||
259 | unsigned paravirt_patch_insns(void *site, unsigned len, | ||
260 | const char *start, const char *end); | ||
261 | |||
262 | |||
251 | /* | 263 | /* |
252 | * This generates an indirect call based on the operation type number. | 264 | * This generates an indirect call based on the operation type number. |
253 | * The type number, computed in PARAVIRT_PATCH, is derived from the | 265 | * The type number, computed in PARAVIRT_PATCH, is derived from the |