Rusty Russell
2007-Apr-18 13:02 UTC
[PATCH] Update lguest's patch code for new paravirt patch architecture
The new patching code means that we don't actually have to do as much
work in lguest's patcher.
We use paravirt_patch_default() for cases we don't want to patch
inline, which automatically handles the "patch iret to use a direct
jump" case.
There's no measurable effect on lguest's virtbench scores tho.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
drivers/lguest/lguest.c | 10 ++--------
drivers/lguest/lguest_asm.S | 1 -
2 files changed, 2 insertions(+), 9 deletions(-)
==================================================================---
a/drivers/lguest/lguest.c
+++ b/drivers/lguest/lguest.c
@@ -388,7 +388,6 @@ static const struct lguest_insns
[PARAVIRT_PATCH(irq_enable)] = { lgstart_sti, lgend_sti },
[PARAVIRT_PATCH(restore_fl)] = { lgstart_popf, lgend_popf },
[PARAVIRT_PATCH(save_fl)] = { lgstart_pushf, lgend_pushf },
- [PARAVIRT_PATCH(iret)] = { lgstart_iret, lgend_iret },
};
static unsigned lguest_patch(u8 type, u16 clobber, void *insns, unsigned len)
{
@@ -396,20 +395,15 @@ static unsigned lguest_patch(u8 type, u1
/* Don't touch it if we don't have a replacement */
if (type >= ARRAY_SIZE(lguest_insns) || !lguest_insns[type].start)
- return len;
+ return paravirt_patch_default(type, clobber, insns, len);
insn_len = lguest_insns[type].end - lguest_insns[type].start;
/* Similarly if we can't fit replacement. */
if (len < insn_len)
- return len;
+ return paravirt_patch_default(type, clobber, insns, len);
memcpy(insns, lguest_insns[type].start, insn_len);
- if (type == PARAVIRT_PATCH(iret)) {
- /* Jumps are relative. */
- u32 off = (u32)lguest_iret - ((u32)insns + insn_len);
- memcpy(insns+1, &off, sizeof(off));
- }
return insn_len;
}
==================================================================---
a/drivers/lguest/lguest_asm.S
+++ b/drivers/lguest/lguest_asm.S
@@ -34,7 +34,6 @@ LGUEST_PATCH(sti, movl $X86_EFLAGS_IF, l
LGUEST_PATCH(sti, movl $X86_EFLAGS_IF, lguest_data+LGUEST_DATA_irq_enabled)
LGUEST_PATCH(popf, movl %eax, lguest_data+LGUEST_DATA_irq_enabled)
LGUEST_PATCH(pushf, movl lguest_data+LGUEST_DATA_irq_enabled, %eax)
-LGUEST_PATCH(iret, .byte 0xE9,0,0,0,0) /* jmp <to-be-patched> */
.text
/* These demark the EIP range where host should never deliver interrupts. */
Maybe Matching Threads
- [PATCH] Update lguest's patch code for new paravirt patch architecture
- [patch 2/9] lguest: the guest code
- [patch 2/9] lguest: the guest code
- [PATCH 1/3] lguest: 2.6.21-mm1 update: lguest-remove-unnecessary-gdt-load.patch
- [PATCH 1/3] lguest: 2.6.21-mm1 update: lguest-remove-unnecessary-gdt-load.patch
