Reputation: 1
I tried to follow tutorials to add a new hypercall for xen, however all of them cannot work because there is no ENTRY(hypercall_table) in entry.S, how to add a new hypercall in recent version of xen?
Upvotes: 0
Views: 404
Reputation: 530
The easy way to create a custom hypercall is to watch how a simple one is declared and try to mimic the behavior. I did this and was able to successfully write one.
The following steps were reproduced in Xen 4.13
Let's assume that I want to create an attack
hypercall that will mimic some malicious behaviors inside Xen.
xen/include/public/xen.h
#define __HYPERVISOR_arch_6 54
#define __HYPERVISOR_arch_7 55
/* Attack Emulation hypercall */
#define __HYPERVISOR_attack 56
/xen/include/xen/hypercall.h
extern long
do_attack(
int cmd,
XEN_GUEST_HANDLE_PARAM(void) arg);
/xen/arch/x86/guest/hypercall_page.S
DECLARE_HYPERCALL(attack)
/xen/arch/x86/hvm/hypercall.c
HYPERCALL(arch_1),
HYPERCALL(attack)
};
xen/arch/x86/hypercall.c
ARGS(arch_1, 1),
ARGS(attack, 2),
};
/xen/common/kernel.c
DO(attack)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)`
{
printk("Entering Attack Hypercall:\t%d\n", cmd);
return 0;
}
Upvotes: 1