Update lguest's patch code for new paravirt patch architecture
PATCH 1/1 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 <[email protected]>
--- drivers/lguest/lguest.c | 10 ++-------- drivers/lguest/lguest_asm.S | 1 - 2 files changed, 2 insertions(+), 9 deletions(-)
===================================================================
drivers/lguest/lguest.c +2 -8
@@ -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; }
===================================================================
drivers/lguest/lguest_asm.S +0 -1
@@ -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. */