Exemplo n.º 1
0
unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
				unsigned long addr, unsigned len)
{
	void *opfunc = get_call_destination(type);
	unsigned ret;

	if (opfunc == NULL)
		/* If there's no function, patch it with a ud2a (BUG) */
		ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
	else if (opfunc == _paravirt_nop)
		/* If the operation is a nop, then nop the callsite */
		ret = paravirt_patch_nop();

	/* identity functions just return their single argument */
	else if (opfunc == _paravirt_ident_32)
		ret = paravirt_patch_ident_32(insnbuf, len);
	else if (opfunc == _paravirt_ident_64)
		ret = paravirt_patch_ident_64(insnbuf, len);

	else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
#ifdef CONFIG_X86_32
		 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
#endif
		 type == PARAVIRT_PATCH(pv_cpu_ops.usergs_sysret32) ||
		 type == PARAVIRT_PATCH(pv_cpu_ops.usergs_sysret64))
		/* If operation requires a jmp, then jmp */
		ret = paravirt_patch_jmp(insnbuf, opfunc, addr, len);
	else
		/* Otherwise call the function; assume target could
		   clobber any caller-save reg */
		ret = paravirt_patch_call(insnbuf, opfunc, CLBR_ANY,
					  addr, clobbers, len);

	return ret;
}
Exemplo n.º 2
0
unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
                unsigned long addr, unsigned len)
{
    void *opfunc = get_call_destination(type);
    unsigned ret;

    if (opfunc == NULL)
        /* If there's no function, patch it with a ud2a (BUG) */
        ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
    else if (opfunc == paravirt_nop)
        /* If the operation is a nop, then nop the callsite */
        ret = paravirt_patch_nop();
    else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
         type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_syscall_ret))
        /* If operation requires a jmp, then jmp */
        ret = paravirt_patch_jmp(insnbuf, opfunc, addr, len);
    else
        /* Otherwise call the function; assume target could
           clobber any caller-save reg */
        ret = paravirt_patch_call(insnbuf, opfunc, CLBR_ANY,
                      addr, clobbers, len);

    return ret;
}